/**
  * This file is part of Medusa.
  *
  * Authors: Uriel Fanelli <uriel.fanelli@gmail.com>
  *          Perthect <perthect@gmail.com>
  *          Marco Bizzarri <Marco.Bizzarri@gmail.com>
  *
  *
  * Medusa is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.

  * Medusa is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.

  * You should have received a copy of the GNU General Public License
  * along with Medusa; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */

#include "initconfig.h"

HandleConfig::HandleConfig()
{
 openConfig();
}

HandleConfig::~HandleConfig()
{   
 closeConfig();
 delete this;
}
void  HandleConfig::openConfig()
{
    QSettings config(CONFIG_FORMAT, QSettings::UserScope,COMPANY_NAME, APPLICATION_NAME);
}

void  HandleConfig::closeConfig()
{
this->config.~QSettings();
}


void HandleConfig::addKey(QString group, QString key, QString value)
{
 this->config.beginGroup(group);
 this->config.setValue(key,value);
 this->config.endGroup();
}

void HandleConfig::delKey(QString group, QString key, QString value)
{
this->config.beginGroup(group);
this->config.remove(key);
this->config.endGroup();
}

void HandleConfig::setKeyValue(QString group, QString key, QString value)
{
 this->config.beginGroup(group);
 this->config.setValue(key,value);
 this->config.endGroup();
}
QString HandleConfig::getKeyValue(QString group, QString key)
{
 this->config.beginGroup(group);
 return this->config.value(key,"").toString();
}


void HandleConfig::freezeConfig()
{
this->config.sync();
this->config_as_array =  config.allKeys();
}
